<include file="public/layout" />
<script src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>分佣记录</h3>
                <h5>网站系统会员索引与管理</h5>
            </div>
        </div>
    </div>
    <!-- 操作说明 -->
    <div id="explanation" class="explanation" style="color: rgb(44, 188, 163); background-color: rgb(237, 251, 248); width: 99%; height: 100%;">
        <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span title="收起提示" id="explanationZoom" style="display: block;"></span>
        </div>
        <ul>
            <li>会员列表管理, 可以给会员群发站内信、邮件等.</li>
            <li>分销系统可以查看会员上下级信息.</li>
        </ul>
    </div>
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>统计分佣总和：<span id="amount_agent">{$amount_agent}</span></h3>
                <h5>(
                    一级代理商：<span id="amount_agent1">{$amount_agent1}</span>
                    二级代理商：<span id="amount_agent2">{$amount_agent2}</span>
                    三级代理商：<span id="amount_agent3">{$amount_agent3}</span>
                    四级代理商：<span id="amount_agent4">{$amount_agent4}</span>
                    五级代理商：<span id="amount_agent5">{$amount_agent5}</span>
                    六级代理商：<span id="amount_agent6">{$amount_agent6}</span>
                    七级代理商：<span id="amount_agent7">{$amount_agent7}</span>
                    )
                </h5>
            </div>
        </div>

        <div class="mDiv">
            <div class="ftitle">
                <h3>分佣列表</h3>
                <h5>(共<span id="user_count"></span>条记录)</h5>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
            <form class="navbar-form form-inline"  id="search-form2" onsubmit="return false">
                <input type="hidden" name="order_by" value="user_id">
                <input type="hidden" name="sort" value="desc">

                <div class="sDiv">
                    <div class="sDiv2">
                        <div class="sDiv2" style="margin-right: 10px;">
                            <input type="text" size="30" name="start_time" id="start_time" value="{$start_time}" placeholder="起始时间" class="qsbox">
                            <input type="button" class="btn" value="起始时间">
                        </div>
                        <div class="sDiv2" style="margin-right: 10px;">
                            <input type="text" size="30" name="end_time" id="end_time" value="{$end_time}" placeholder="截止时间" class="qsbox">
                            <input type="button" class="btn" value="截止时间">
                        </div>

                        <input type="submit" class="btn" onclick="ajax_get_table('search-form2',1)" value="搜索">
                    </div>
                </div>
            </form>
        </div>

        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0">
                    <thead>
                    <tr>
                        <th class="sign" axis="col0">
                            <div style="width: 24px;"><i class="ico-check"></i></div>
                        </th>
                        <th align="left" abbr="f.id" axis="col3" class="">
                            <div style="text-align: center; width: 40px;" class="">ID</div>
                        </th>
                        <th align="left" abbr="f.order_id" axis="col3" class="">
                            <div style="text-align: center; width: 80px;" class="">订单ID</div>
                        </th>
                        <th align="left" abbr="user_name" axis="col4" class="">
                            <div style="text-align: center; width: 150px;" class="">会员昵称</div>
                        </th>
                        <th align="center" abbr="f.order_money" axis="col5" class="">
                            <div style="text-align: center; width: 50px;" class="">订单金额</div>
                        </th>

                        <th align="center" abbr="nickname1" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">一级代理商</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 50px;" class="">所得分润</div>
                        </th>

                        <th align="center" abbr="nickname2" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">二级代理商</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 50px;" class="">所得分润</div>
                        </th>

                        <th align="center" abbr="nickname3" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">三级代理商</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 50px;" class="">所得分润</div>
                        </th>

                        <th align="center" abbr="nickname4" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">四级代理商</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 50px;" class="">所得分润</div>
                        </th>

                        <th align="center" abbr="nickname5" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">五级代理商</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 50px;" class="">所得分润</div>
                        </th>

                        <th align="center" abbr="nickname6" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">六级代理商</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 50px;" class="">所得分润</div>
                        </th>

                        <th align="center" abbr="nickname7" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">七级代理商</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 50px;" class="">所得分润</div>
                        </th>

                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 50px;" class="">介绍</div>
                        </th>
                        <th align="center" abbr="time" axis="col6" class="">
                            <div style="text-align: center; width: 120px;" class="">分佣日期</div>
                        </th>
                        <th style="width:100%" axis="col7">
                            <div></div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton">
                    <a href="{:U('User/export_commission')}">
                        <div class="add" title="导出分拥记录">
                            <span><i class="fa fa-share"></i>导出分拥记录</span>
                        </div>
                    </a>
                </div>

            </div>
            <div style="clear:both"></div>
        </div>
        <div class="bDiv" style="height: auto;" id="ajax_return">
        </div>
    </div>
</div>
<script>
    $(document).ready(function(){
        $('#start_time').layDate();
        $('#end_time').layDate();
        // 点击刷新数据
        var ssort = 'sdesc';
        var on_sclick = 0;
        $('.hDivBox > table>thead>tr>th').hover(
            function () {
                if(typeof($(this).attr('abbr')) == "undefined"){
                    return false;
                }
                $(this).addClass('thOver');
                if($(this).hasClass('sorted')){
                    if(ssort == 'sdesc'){
                        $(this).find('div').removeClass('sdesc');
                        $(this).find('div').addClass('sasc');
                    }else{
                        $(this).find('div').removeClass('sasc');
                        $(this).find('div').addClass('sdesc');
                    }
                }else{
                    $(this).find('div').addClass(ssort);
                }
            }, function () {
                    if(typeof($(this).attr('abbr')) == "undefined"){
                        return false;
                    }
                    if(on_sclick == 0){
                        if($(this).hasClass('sorted')){
                            if(ssort == 'sdesc'){
                                $(this).find('div').removeClass('sasc');
                                $(this).find('div').addClass('sdesc');
                            }else{
                                $(this).find('div').removeClass('sdesc');
                                $(this).find('div').addClass('sasc');
                            }
                        }else{
                            $(this).find('div').removeClass(ssort);
                        }
                    }
                    $(this).removeClass("thOver");
                    on_sclick = 0;
            }
        );
        $('.hDivBox > table>thead>tr>th').click(function(){
            if(typeof($(this).attr('abbr')) == "undefined"){
                return false;
            }
            if($(this).hasClass('sorted')){
                $(this).find('div').removeClass(ssort);
                if(ssort == 'sdesc'){
                    ssort = 'sasc';
                }else{
                    ssort = 'sdesc';
                }
                $(this).find('div').addClass(ssort);
                on_sclick = 1;
            }else{
                $('.hDivBox > table>thead>tr>th').removeClass('sorted');
                $('.hDivBox > table>thead>tr>th').find('div').removeClass(ssort);
                $(this).addClass('sorted');
                $(this).find('div').addClass(ssort);
                var hDivBox_th_index = $(this).index();
                var flexigrid_tr =   $('#flexigrid > table>tbody>tr')
                flexigrid_tr.each(function(){
                    $(this).find('td').removeClass('sorted');
                    $(this).children('td').eq(hDivBox_th_index).addClass('sorted');
                });
            }
            sort($(this).attr('abbr'));
        });

        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
        ajax_get_table('search-form2',1);

    });
    //选中全部
    $('.hDivBox .sign').click(function(){
        var sign = $('#flexigrid > table>tbody>tr');
       if($(this).parent().hasClass('trSelected')){
           sign.each(function(){
               $(this).removeClass('trSelected');
           });
           $(this).parent().removeClass('trSelected');
       }else{
           sign.each(function(){
               $(this).addClass('trSelected');
           });
           $(this).parent().addClass('trSelected');
       }
    })

    // ajax 抓取页面
    function ajax_get_table(tab,page){
        var search_key = $.trim($('#search_key').val());
        if(search_key.length > 0){
            if(checkEmail(search_key)){
                $('#input-email').val(search_key);
            }else if(checkMobile(search_key)){
                $('#input-mobile').val(search_key);
            }else{
                layer.alert('请输入正确的邮箱或者手机号码', {icon: 2});
            }
        }
        cur_page = page; //当前页面 保存为全局变量
        $.ajax({
            type : "POST",
            url:"/index.php/Admin/user/ajaxcommission/p/"+page,//+tab,
            data : $('#'+tab).serialize(),// 你的formid
            success: function(data){
                $("#ajax_return").html('');
                $("#ajax_return").append(data);
            }
        });
    }


    // 点击排序
    function sort(field)
    {
        $("input[name='order_by']").val(field);
        var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='sort']").val(v);
        ajax_get_table('search-form2',cur_page);
    }


</script>
</body>
</html>